/*
 * Copyright (c) 2009, Hamish Morgan. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * 3. Neither the name of the University of Sussex nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * EntityEditFrame.java
 *
 * Created on 02-Sep-2009, 15:30:21
 */
package locusts.server.admin;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.text.NumberFormatter;
import locusts.common.entities.Actor;
import locusts.common.entities.Entity;
import locusts.server.Game;

/**
 * A form to edit the properties of a single Entity or Actor object.
 * 
 * @author Hamish Morgan
 */
public class EditEntityFrame extends javax.swing.JFrame {

    private Entity entity;
    private Game game;
    private NumberFormatter numberFormatter;

    /** Creates new form EntityEditFrame */
    public EditEntityFrame(Game game, Entity e) {
        entity = e;
        this.game = game;

        DecimalFormat decimalFormat = new DecimalFormat("0.###");
        numberFormatter = new NumberFormatter(decimalFormat);
        numberFormatter.setOverwriteMode(true);
        numberFormatter.setAllowsInvalid(false);

        initComponents();
        try {
            loadData();
        } catch (ParseException ex) {
            Logger.getLogger(EditEntityFrame.class.getName()).
                    log(Level.SEVERE, null, ex);
        }
        pack();
    }

    private void loadData() throws ParseException {
        idTextField.setText(numberFormatter.valueToString(entity.getId()));
        idTextField.setEditable(false);


        entityTypeComboBox.setSelectedIndex(entity.getTypeId());

        xTextField.setText(numberFormatter.valueToString(entity.getX()));
        yTextField.setText(numberFormatter.valueToString(entity.getY()));
        zOrderTextField.setText(numberFormatter.valueToString(
                entity.getzOrder()));
        energyTextField.setText(numberFormatter.valueToString(
                entity.getEnergy()));
        orientationTextField.setText(numberFormatter.valueToString(entity.
                getOrientation()));
        aliveCheckBox.setSelected(entity.isAlive());

        if (entity instanceof Actor) {
            Actor actor = (Actor) entity;
            vxTextField.setText(numberFormatter.valueToString(actor.getVX()));
            vyTextField.setText(numberFormatter.valueToString(actor.getVY()));
            axTextField.setText(numberFormatter.valueToString(actor.getAX()));
            ayTextField.setText(numberFormatter.valueToString(actor.getAY()));
        } else {
            actorPanel.setVisible(false);
        }
    }

    private void saveData() {

        int newTypeId = entityTypeComboBox.getSelectedIndex();
        if(newTypeId != entity.getTypeId()) {
            entity.setTypeId(newTypeId);
            entity.setModified();
        }

        final double newX = Double.valueOf(xTextField.getText());
        if (newX != entity.getX()) {
            entity.setX(newX);
            entity.setModified();
        }

        final double newY = Double.valueOf(yTextField.getText());
        if (newY != entity.getY()) {
            entity.setY(newY);
            entity.setModified();
        }

        final double newOr =
                Double.valueOf(orientationTextField.getText());
        Double.valueOf(orientationTextField.getText());
        if (newOr != entity.getOrientation()) {
            entity.setOrientation(newOr);
            entity.setModified();
        }
        final int newZ =
                Integer.valueOf(zOrderTextField.getText());
        if (newZ != entity.getzOrder()) {
            entity.setzOrder(newZ);
            entity.setModified();
        }
        final double newEnergy =
                Double.valueOf(energyTextField.getText());
        if (newEnergy != entity.getEnergy()) {
            entity.setEnergy(newEnergy);
            entity.setModified();
        }
        final boolean newAlive = aliveCheckBox.isSelected();
        if (newAlive != entity.isAlive()) {
            entity.setAlive(newAlive);
            entity.setModified();
        }
        if (entity instanceof Actor) {
            Actor actor = (Actor) entity;
            final double newVX =
                    Double.valueOf(vxTextField.getText());
            if (newVX != actor.getVX()) {
                actor.setVelocityX(newVX);
                actor.setModified();
            }
            final double newVY =
                    Double.valueOf(vyTextField.getText());
            if (newVY != actor.getVY()) {
                actor.setVelocityY(newVY);
                actor.setModified();
            }
            final double newAX =
                    Double.valueOf(axTextField.getText());
            if (newAX != actor.getAX()) {
                actor.setAccelerationX(newAX);
                actor.setModified();
            }
            final double newAY =
                    Double.valueOf(ayTextField.getText());
            if (newAY != actor.getAY()) {
                actor.setAccelerationY(newAY);
                actor.setModified();
            }
        }
        xTextField.setText(String.valueOf(entity.getX()));
        yTextField.setText(String.valueOf(entity.getY()));
        zOrderTextField.setText(String.valueOf(entity.getzOrder()));
        energyTextField.setText(String.valueOf(entity.getEnergy()));
        orientationTextField.setText(String.valueOf(entity.getOrientation()));
        aliveCheckBox.setSelected(entity.isAlive());
        if (entity instanceof Actor) {
            Actor actor = (Actor) entity;
            vxTextField.setText(String.valueOf(actor.getVX()));
            vyTextField.setText(String.valueOf(actor.getVY()));
            axTextField.setText(String.valueOf(actor.getAX()));
            ayTextField.setText(String.valueOf(actor.getAY()));
        } else {
            actorPanel.setVisible(false);
        }
    }

    private void close() {
        setVisible(false);
        dispose();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        entityPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        idTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        xTextField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        orientationTextField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        zOrderTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        energyTextField = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        yTextField = new javax.swing.JTextField();
        aliveCheckBox = new javax.swing.JCheckBox();
        entityTypeComboBox = new javax.swing.JComboBox();
        actorPanel = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        vyTextField = new javax.swing.JTextField();
        vxTextField = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        ayTextField = new javax.swing.JTextField();
        axTextField = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        applyButton = new javax.swing.JButton();
        saveButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 100, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        entityPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Entity"));

        jLabel1.setText("Id");

        idTextField.setColumns(6);
        idTextField.setEditable(false);
        idTextField.setText("jTextField1");
        idTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idTextFieldActionPerformed(evt);
            }
        });

        jLabel2.setText("Type");

        xTextField.setColumns(6);
        xTextField.setText("jTextField1");

        jLabel3.setText("Position");

        orientationTextField.setColumns(6);
        orientationTextField.setText("jTextField1");

        jLabel4.setText("Orientation");

        zOrderTextField.setColumns(6);
        zOrderTextField.setText("jTextField1");

        jLabel5.setText("Z Order");

        energyTextField.setColumns(6);
        energyTextField.setText("jTextField1");

        jLabel6.setText("Energy");

        yTextField.setColumns(6);
        yTextField.setText("jTextField1");
        yTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                yTextFieldActionPerformed(evt);
            }
        });

        aliveCheckBox.setText("Alive");
        aliveCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aliveCheckBoxActionPerformed(evt);
            }
        });

        entityTypeComboBox.setModel(new EntityTypeComboBoxModel(game.getEntityTypes()));

        org.jdesktop.layout.GroupLayout entityPanelLayout = new org.jdesktop.layout.GroupLayout(entityPanel);
        entityPanel.setLayout(entityPanelLayout);
        entityPanelLayout.setHorizontalGroup(
            entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(entityPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(entityPanelLayout.createSequentialGroup()
                        .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                        .add(17, 17, 17))
                    .add(entityPanelLayout.createSequentialGroup()
                        .add(entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE)
                            .add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE)
                            .add(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
                .add(entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(entityPanelLayout.createSequentialGroup()
                        .add(xTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(yTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(entityPanelLayout.createSequentialGroup()
                        .add(idTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 119, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(aliveCheckBox))
                    .add(orientationTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(zOrderTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(energyTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(entityTypeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        entityPanelLayout.setVerticalGroup(
            entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(entityPanelLayout.createSequentialGroup()
                .add(entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(idTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel1)
                    .add(aliveCheckBox))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2)
                    .add(entityTypeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(xTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(yTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(orientationTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel5)
                    .add(zOrderTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(entityPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel6)
                    .add(energyTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(31, Short.MAX_VALUE))
        );

        actorPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Actor"));

        jLabel8.setText("Velocity");

        vyTextField.setColumns(6);
        vyTextField.setText("jTextField1");

        vxTextField.setColumns(6);
        vxTextField.setText("jTextField1");

        jLabel10.setText("Acceleration");

        ayTextField.setColumns(6);
        ayTextField.setText("jTextField1");

        axTextField.setColumns(6);
        axTextField.setText("jTextField1");

        org.jdesktop.layout.GroupLayout actorPanelLayout = new org.jdesktop.layout.GroupLayout(actorPanel);
        actorPanel.setLayout(actorPanelLayout);
        actorPanelLayout.setHorizontalGroup(
            actorPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(actorPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(actorPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(actorPanelLayout.createSequentialGroup()
                        .add(jLabel10)
                        .add(18, 18, 18)
                        .add(axTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(ayTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(actorPanelLayout.createSequentialGroup()
                        .add(jLabel8)
                        .add(46, 46, 46)
                        .add(vxTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(vyTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(23, Short.MAX_VALUE))
        );
        actorPanelLayout.setVerticalGroup(
            actorPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(actorPanelLayout.createSequentialGroup()
                .add(actorPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(vxTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel8)
                    .add(vyTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(actorPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(axTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel10)
                    .add(ayTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        applyButton.setText("Apply");
        applyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                applyButtonActionPerformed(evt);
            }
        });
        jPanel2.add(applyButton);

        saveButton.setText("Save");
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });
        jPanel2.add(saveButton);

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });
        jPanel2.add(cancelButton);

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, entityPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(actorPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(6, 6, 6)
                .add(entityPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(actorPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(48, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(jPanel1);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.LINE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void idTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_idTextFieldActionPerformed

    private void aliveCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aliveCheckBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_aliveCheckBoxActionPerformed

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        // TODO add your handling code here:
        saveData();
        close();
    }//GEN-LAST:event_saveButtonActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        // TODO add your handling code here:
        close();
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void applyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed
        // TODO add your handling code here:
        saveData();
    }//GEN-LAST:event_applyButtonActionPerformed

    private void yTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_yTextFieldActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel actorPanel;
    private javax.swing.JCheckBox aliveCheckBox;
    private javax.swing.JButton applyButton;
    private javax.swing.JTextField axTextField;
    private javax.swing.JTextField ayTextField;
    private javax.swing.JButton cancelButton;
    private javax.swing.JTextField energyTextField;
    private javax.swing.JPanel entityPanel;
    private javax.swing.JComboBox entityTypeComboBox;
    private javax.swing.JTextField idTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField orientationTextField;
    private javax.swing.JButton saveButton;
    private javax.swing.JTextField vxTextField;
    private javax.swing.JTextField vyTextField;
    private javax.swing.JTextField xTextField;
    private javax.swing.JTextField yTextField;
    private javax.swing.JTextField zOrderTextField;
    // End of variables declaration//GEN-END:variables
}
